import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/double_prevention/double_get_all_measures_selection/double_get_all_measures_selection_controller.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/get_all_measures_by_id_and_level_entity.dart';

/// 指定层级的风险事件选择控件 获取层级下所有的措施
class DoubleGetAllMeasuresSelectionPage extends StatelessWidget {
  DoubleGetAllMeasuresSelectionPage({super.key});

  final controller = Get.put(DoubleGetAllMeasuresSelectionController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleText: '措施选择',
      ),
      body: GetBuilder(
          init: controller,
          builder: (_) {
            return Container(
                padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w, bottom: 80.w),
                alignment: Alignment.topCenter,
                color: const Color(0xffF5F5F6),
                child: Column(
                  children: [
                    // _getSearchEnterWidget(),
                    AppGaps.vGap14,
                    Expanded(
                      child: ListView.separated(
                        itemCount: controller.dataList.length,
                        itemBuilder: (context, index) {
                          final GetAllMeasuresByIdAndLevelEntity item = controller.dataList[index];
                          return Container(
                              padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.w),
                              decoration: item.getIsChecked()
                                  ? BoxDecoration(
                                      borderRadius: BorderRadius.circular(8.w),
                                      gradient: const LinearGradient(
                                          //渐变位置
                                          begin: Alignment.centerLeft,
                                          end: Alignment.centerRight,
                                          //渐变颜色[始点颜色, 结束颜色]
                                          colors: [Color(0xff3B62FF), Color(0xff9FB2FF)]))
                                  : BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8.w)),
                              child: Row(
                                children: [
                                  item.getIsChecked()
                                      ? SvgPicture.asset(
                                          AppImages.icon_person_select,
                                          width: 28.w,
                                          height: 28.w,
                                        )
                                      : SvgPicture.asset(
                                          AppImages.icon_person_un_select,
                                          width: 28.w,
                                          height: 28.w,
                                        ),
                                  AppGaps.hGap12,
                                  Expanded(
                                      child: Text(
                                    item.getShowName(),
                                    style: TextStyle(
                                        color: item.getIsChecked() ? const Color(0xffffffff) : const Color(0xff262F38),
                                        height: 1.2,
                                        fontWeight: FontWeight.w400,
                                        fontSize: 16.sp),
                                  )),
                                ],
                              )).clickOnce(() {
                            controller.onTap(item);
                          });
                        },
                        separatorBuilder: (BuildContext context, int index) {
                          return AppGaps.vGap20;
                        },
                      ),
                    )
                  ],
                ));
          }),
      bottomSheet: Container(
        padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
        decoration: BoxDecoration(
          color: Colors.white,
          boxShadow: [
            BoxShadow(
              color: const Color(0xffBCBCC5).withOpacity(0.3), // 阴影颜色
              offset: const Offset(0, -5), // 阴影的偏移量，向上偏移，即上方阴影
              blurRadius: 10.0, // 阴影的模糊半径
              spreadRadius: 2.0, // 阴影的扩散半径
            ),
          ],
        ),
        child: Row(
          children: [
            Expanded(
              child: ElevatedButton(
                style: ElevatedButton.styleFrom(
                  backgroundColor: AppColors.blue_button,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(22.r),
                  ),
                ),
                onPressed: controller.complete,
                child: Text(
                  '确定',
                  style: TextStyle(
                    fontSize: 16.sp,
                    color: Colors.white,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
